﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Assets.Scripts.TDuApp;
using System.Collections;
using static TDuProfile;
using UnityEngine.SceneManagement;

class TDuMainEntry : MonoBehaviour
{
    public TDuAppMaker m_appMaker;
    public static Profile m_profile;//配置文件
    public void Start()
    {

        m_profile = TDuProfile.Instance.m_profile;//从选择场景拿过来
        string str = "Model/" + m_profile.resourcePath + m_profile.modelName;
        print(str);
        GameObject.Instantiate(Resources.Load(str)).name = m_profile.modelName;
        string strExmFullPath = Application.streamingAssetsPath + "/" + m_profile.resourcePath + m_profile.strExmFullPath;
        //string strExmFullPath = Application.streamingAssetsPath + "/Resources/Scene/MKJC.EXM";
        Debug.Log("【OutputInfo】----[Start]-Exm Full Path:" + strExmFullPath);

        m_appMaker = new TDuAppMaker(strExmFullPath);
        m_appMaker.prepareApp();
        StartCoroutine(m_appMaker.initApp());
        m_appMaker.startApp();
    }

    public void Update()
    {
        m_appMaker.runApp();
    }

    public void LateUpdate()
    {
        m_appMaker.lateRunApp();
        if(Input.GetKeyDown(KeyCode.P))
        {
            BackToMainScene();
        }
    }


    public void BackToMainScene()
    {
        SceneManager.LoadScene("MainSystem",LoadSceneMode.Single);
    }

}
